﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NeuralNetworks.FileParsing
{
    class LayerPartFactory
    {
        public static LayerPart getPart(String desc)
        {
            string[] parts = desc.Split(':');
            try
            {
                if (parts[0].Equals("r"))
                {
                    double min = double.Parse(parts[1]);
                    double max = double.Parse(parts[2]);
                    Console.WriteLine("range");
                    return new RandomRange(min, max);
                }
                int currentLayerNeuron = int.Parse(parts[0]) - 1;
                double w = double.Parse(parts[2]);
                if (parts[1].Equals("b"))
                {
                    return new Bias(currentLayerNeuron, w);
                }
                else
                {
                    int nextLayerNeuron = int.Parse(parts[1]) - 1;
                    return new ConnectionWeight(currentLayerNeuron, nextLayerNeuron, w);
                }
            }
            catch (FormatException)
            {
                return new ActvFunction(desc);
            }
        }
    }
}
